import java.text.DateFormatSymbols;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Locale;

/**
 * 
 */

/**
 * @author mingfan
 *
 */
public class CalendarTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		Locale.setDefault(Locale.FRANCE);

		GregorianCalendar day = new GregorianCalendar();

		// Calculate indent
		day.set(Calendar.DAY_OF_MONTH, 1);
		int dayIndex = day.get(Calendar.DAY_OF_WEEK);
		int indent = 0;
		while (dayIndex != day.getFirstDayOfWeek()) {
			indent ++;
			day.add(Calendar.DAY_OF_MONTH, -1);
			dayIndex = day.get(Calendar.DAY_OF_WEEK);
		}

		// Print out title: week day name
		String[] weekDayNames = DateFormatSymbols.getInstance().getShortWeekdays();
		do {
			System.out.printf("%4s", weekDayNames[day.get(Calendar.DAY_OF_WEEK)]);
			day.add(Calendar.DAY_OF_WEEK, 1);
		} while (day.get(Calendar.DAY_OF_WEEK) != day.getFirstDayOfWeek());
		System.out.println();

		
		for (int i = 0; i < indent; i++) {
			System.out.printf("    ");
		}
		
		day = new GregorianCalendar();
		int today = day.get(Calendar.DAY_OF_MONTH);
		int month = day.get(Calendar.MONTH);
		
		day.set(Calendar.DAY_OF_MONTH, 1);
		do {
			dayIndex = day.get(Calendar.DAY_OF_MONTH);
			if (dayIndex == today) {
				System.out.printf("%3s*", dayIndex);
			} else {
				System.out.printf("%3s ", dayIndex);
			}
			day.add(Calendar.DAY_OF_MONTH, 1);
			if (day.get(Calendar.DAY_OF_WEEK) == day.getFirstDayOfWeek()) {
				System.out.println();
			}
		} while (month == day.get(Calendar.MONTH));
	}
}
